<template>
  <div class="xiangding-img">
    <div class="img-swiper" v-if="imgFiles && imgFiles.length">
      <div class="title">{{ imgFiles[activeIndex].fileName }}</div>
      <el-carousel :interval="5000" arrow="always" height="100%" @change="hanldeChange">
        <el-carousel-item v-for="item in imgFiles" :key="item.id">
          <el-image
            style="width: 100%;height: 100%"
            :src="item.filePath ? item.filePath.replace('/file/maneuver-scenario/','maneuver-scenario-files/') : ''"
          ></el-image>
        </el-carousel-item>
      </el-carousel>
    </div>
     <el-empty v-else description="暂无想定图片" :image-size="100"></el-empty>
  </div>
</template>

<script>
export default {
  props: ["detail"],
  computed: {
    imgFiles() {
      if (this.detail && this.detail.imgFiles) {
        return this.detail.imgFiles;
      } else {
        return [];
      }
    },
  },
  data() {
    return {
      activeIndex: 0,
    };
  },
  methods: {
    hanldeChange(index1, index2) {
      this.activeIndex = index1;
    },
  },
};
</script>

<style lang="less">
.xiangding-img {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  .img-swiper {
    width: 69%;
    margin: 0 auto;
    height: 51.5%;
    position: relative;
    .el-carousel {
      width: 100%;
      height: 100%;
      .el-carousel__arrow {
        width: 32px;
        height: 64px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 0;
        i {
          font-size: 20px;
        }
      }
      .el-carousel__arrow--left {
        left: 0;
      }
      .el-carousel__arrow--right {
        right: 0;
      }
    }
  }
  .title {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    padding-left: 17px;
    font-size: 16px;
    font-weight: 400;
    color: #ffffff;
    line-height: 40px;
    z-index: 99;
    pointer-events: auto;
  }
}
</style>
